﻿import QtQuick 2.0

import "../../js/UI.js" as Style
import "../../js/util.js" as Util

Title {
    property Item leftItem: null
    property Item centerItem: null
    property Item rightItem: null
    property alias m_text: m_Text.text
    property alias m_Text: m_Text
    property alias m_textcol: m_Text.color
    property alias m_font: m_Text.font.pointSize
    property alias m_linecolor: line.color
    property bool m_titlevisible: true
    property alias imagvisible: imag.visible
    property alias m_img: imag
    property alias choseid: choseid
    signal backSignal
    signal meetchoseSignal
    property  alias   m_backVisble: leftItemArea.visible
    Loader {
        anchors.fill: parent
        anchors.topMargin:  Qt.platform.os != "ios" ? 0 : (__deviceManager.isIPhoneX ? 0 : 20)
        Binding { target: leftItem; property: "parent"; value: leftItemArea }
        Binding { target: centerItem; property: "parent"; value: centerItemArea }
        Binding { target: rightItem; property: "parent"; value: rightItemArea }

        Rectangle {
            id: leftItemArea
            anchors.left: parent.left
            width: height
            height: parent.height
            color: !mouse.pressed ? "transparent" : "#e1e1e1"

            Image {
                id:imag
                height:Util.isMobileDevice() ? 0.4 * m_lineValue : 20
                width: height
                fillMode: Image.PreserveAspectFit
                anchors.centerIn: parent
                source: "qrc:/image/back.png"
            }

            MouseArea {
                id: mouse
                anchors.fill: parent
                onClicked: backSignal()
            }
        }

        Rectangle {
            id: centerItemArea
            anchors.centerIn: parent
            //            anchors.left: leftItemArea.right
            //            anchors.right: rightItemArea.left
            width: parent.width - 2* parent.height
            height: parent.height
            color: "transparent"
            AText {
                id: m_Text
                visible: m_titlevisible
                width: parent.width
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                anchors.leftMargin: (parent.width-contentWidth)/2
                color: Style.fonttilteColor
                font.pointSize: Style.fontTitleSize
                elide: Text.ElideRight
                text: Util.APP_MAIN_NAME
                //verticalAlignment: Text.AlignRight
                MouseArea{
                    id:choseid
                    enabled: false
                    anchors.fill: parent
                    onClicked: {
                        meetchoseSignal()
                    }
                }
            }
        }

        Rectangle {
            id: rightItemArea
            anchors.right: parent.right
            width: height
            height: parent.height
            color: "transparent"
        }
    }

    Horizontal_line{
        id:line
        width: parent.width
        anchors.bottom: parent.bottom
    }
}

